package com.pda.gongpin.adapter;

import android.text.TextUtils;
import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import com.pda.gongpin.R;
import com.pda.gongpin.bean.ImageBean;
import com.wangshen.base.ui.mvp.base.adapter.BaseAdapter;

import java.util.List;

public class ImageAdapter extends BaseAdapter<ImageBean> {
    public ImageAdapter(int layoutResId, @Nullable List<ImageBean> data) {
        super(layoutResId, data);
        addChildClickViewIds(R.id.iv_image);
        addChildClickViewIds(R.id.iv_delete);
    }

    @Override
    protected void convert(BaseViewHolder helper, ImageBean item) {
        super.convert(helper, item);
        ImageView imageView=helper.getView(R.id.iv_image);
        if (TextUtils.isEmpty(item.getPath())){
            imageView.setImageResource(R.mipmap.icon_img);
            helper.setVisible(R.id.iv_delete,false);
        }else {
            Glide.with(getContext()).load(item.getPath()).into(imageView);
            helper.setVisible(R.id.iv_delete,true);
        }

    }
}
